<?php


class Stock extends Admin_controller
{
	
	
	public function __construct()
	{
		parent::__construct();
		$this->load->model('stock_mdl','stock');
	}
	
	/**
	 * 
	 * add stock
	 */
	public function addstock()
	{
		$cardnum = $this->input->post('cardnum');
		$productid = $this->input->post('productid');
		
		if (!empty($cardnum) && !empty($productid)){
			
			$data['cardnum'] = $cardnum;
			$data['productid'] = $productid;
			echo $this->stock->_addStock($data);		
		} else {
			echo 'asdf';
		}
	}
	
	public function delstock()
	{
		$id = $this->input->post('id');
		if(intval($id)){
			echo $this->stock->_delStock($id);
		}else{
			echo '0';
		}
	}
	
	/**
	 * ajax添加活动奖品
	 */
	public function ajaxstock()
	{
		
		$this->load->model('product_mdl','product');
		$this->load->model('stock_mdl','stock');
		
		$product = array();
		$product = $this->product->get_product_list(false);
		
		$stock = array();
		$stock = $this->stock->get_stock_list(false);
		$str = '<li><select name="">';
		foreach($product as $k => $v){
			$str.= '<option value="1">1</option>';
		}
		$str.='</select></li>';
		echo $str;

	}
}